home *** CD-ROM | disk | FTP | other *** search
- /*
- DUFTP
- */
-
- // Local Filesystem Handling
-
- #include <DULIB.H>
- #include <MINTBIND.H>
- #include <FILESYS.H>
- #include <ERRNO.H>
- #include "globals.h"
- #include "ls2filel.h"
- #include "local_fs.h"
-
- // get a directory listing from the current local directory
-
- void get_local_files(void)
- {
- char dirbuf[FMSIZE],*fname;
- char cdir[FMSIZE];
- char namebuf[FMSIZE];
- XATTR a;
- short f;
- file_list *nf;
- long dhandle,r;
-
- if (local_directory) dispose_file_list(local_directory);
-
- fname=dirbuf+4;
-
- sprintf(cdir,"%s",current_local_path);
- for(f=0; f<FMSIZE; f++) if (cdir[f]=='/') cdir[f]='\\';
-
- dhandle=Dopendir(cdir,0);
-
- if ((dhandle&0xFF000000)==0xFF000000)
- {
- dhandle=dhandle&0xFF;
- if (dhandle==EPATH)
- {
- printf("Invalid path\n");
- return;
- }
- if (dhandle==EACCESS)
- {
- printf("Directory not accessible\n");
- return;
- }
- if (dhandle==ENOMEM)
- {
- printf("Kernal is out of memory\n");
- return;
- }
- return;
- }
- local_directory=NULL;
- graf_mouse(HOURGLASS,NULL);
- while(Dreaddir(FMSIZE,dhandle,dirbuf)==0)
- {
- if (!((fname[0]=='.')&&(fname[1]=='\0'))
- &&(!((fname[0]=='.')&&(fname[1]=='.'))))
- {
- sprintf(namebuf,"%s\\%s",cdir,fname);
- r=Fxattr( 0, namebuf, &a);
- nf=(file_list*)malloc(sizeof(file_list));
-
- nf->size=a.size;
-
- if ((a.mode&S_IFMT)==S_IFDIR)
- {
- sprintf(nf->name," %s",fname,a.size);
- nf->is_directory=TRUE;
- }else{
- sprintf(nf->name," %s (%d)",fname,a.size);
- nf->is_directory=FALSE;
- }
-
- if ((a.mode&S_IFMT)==S_IFLNK)
- {
- nf->name[1]='';
- nf->is_symlink=TRUE;
- }else{
- nf->is_symlink=FALSE;
- }
-
- nf->owner_read=TRUE;
- nf->public_read=TRUE;
- sprintf(nf->owner,"root");
- nf->next=local_directory;
- local_directory=nf;
- }
- }
-
- graf_mouse(ARROW,NULL);
- Dclosedir(dhandle);
- }
-